package com.t9;

import org.junit.runner.FilterFactory;

import java.util.Arrays;

/**
 * Created by xuyiwei on 2018/7/20.
 */
class Splitter12 implements Processor11 {
    @Override
    public String name() { return null; }
    @Override
    public Object process(Object input) { return null; }
}
public class FilterAdapter implements  Processor11{
    Filter filter ;
    public FilterAdapter(Filter filter) {
        this.filter = filter;
    }
    @Override
    public String name() {
        return filter.name();
    }
    @Override
    public Object process(Object input) {
        //这里还使用了一种代理的方式 可以扩展和
        return filter.process((Waveform) input);
    }

    public static void process(Processor11 p ,Object s){
        System.out.println("Using Processor "+p.name());
        System.out.println(p.process(s));
    }

    public static void main(String[] args) {
        Waveform w = new Waveform();
        //适配器模式 就可以完美的吧fiter类型的值  作为一个参数传递进filter方法
        FilterAdapter.process(new FilterAdapter(new LosPass(1.0)),w);
        FilterAdapter.process(new FilterAdapter(new HighPass(1.0)),w);
        FilterAdapter.process(new FilterAdapter(new BandPass(1.0,2.0)),w);

        FilterAdapter.process(new Splitter12(),w);
    }
}


